﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

namespace UI.Web.SailHeroSoftAuthorization.Helper
{
    public class PathHelper
    {
        /// <summary>
        /// 得到当前的相对路径
        /// </summary>
        /// <returns></returns>
        public string GetLocalPath()
        {
            string localPath = System.Reflection.Assembly.GetExecutingAssembly().Location.ToString();
            FileInfo Finfo = new System.IO.FileInfo(localPath);
            return urlconvertor(Finfo.DirectoryName);
        }

        private string urlconvertor(string imagesurl1)
        {
          
            string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString());//获取程序根目录
            tmpRootDir = tmpRootDir.Replace(@"/", @"\");
            string imagesurl2 = imagesurl1.ToLower().Replace(tmpRootDir.ToLower(), ""); //转换成相对路径
            imagesurl2 = @"/" + imagesurl2.Replace(@"\", @"/");
            return imagesurl2;
        }



    }
}